package com.itheima.itcasthealth.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.itheima.itcasthealth.common.Result;
import com.itheima.itcasthealth.entiry.Member;
import com.itheima.itcasthealth.entiry.User;
import com.itheima.itcasthealth.mapper.MemberMapper;
import com.itheima.itcasthealth.service.MemberService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;

@Service
public class MemberServiceImpl implements MemberService {

    @Autowired
    private MemberMapper memberMapper;

    @Override
    public Result login(String phone) {



        LambdaQueryWrapper<Member> wapper = new LambdaQueryWrapper<>();
        wapper.eq(Member::getPhoneNumber,phone);
        Member member = memberMapper.selectOne(wapper);

        if (member == null){
            member = new Member();
            member.setPhoneNumber(phone);
            member.setRegTime(new Date());
            member.setPassword("e10adc3949ba59abbe56e057f20f883e");

            memberMapper.insert(member);
        }



        return new Result(true,"查询成功",member);
    }
}
